package hu.vissy.yacap.option;

import hu.vissy.yacap.exception.CommandLineParserException;

/**
 * General string-based option
 *
 * @author balage
 *
 */
public class StringOption extends CommandLineOption<String> {

    /**
     * Builder utility class to create option.
     *
     * @author balage
     *
     */
    public static class Builder extends CommandLineOptionBuilder<String, Builder> {
        public Builder(String longForm) {
            super(String.class, longForm);
        }

        /**
         * Uses covariant return type to precast result.
         *
         */
        @Override
        public StringOption getInstance() {
            return (StringOption) super.getInstance();
        }

        @Override
        protected CommandLineOption<String> createInstance() {
            return new StringOption(longForm);
        }

        @Override
        protected Builder getThis() {
            return this;
        }
    }

    /**
     * Constructor.
     *
     * Hidden. Use the {@linkplain StringOption.Builder} class for construction.
     *
     * @param longForm
     *            The long name of the command.
     */
    StringOption(String longForm) {
        super(String.class, longForm);
    }

    @Override
    public String parseValue(String valueString) throws CommandLineParserException {
        return valueString;
    }

    @Override
    public String getDefaultValue() {
        return super.getDefaultValue();
    }

}
